package com.ruoyi.office.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import com.ruoyi.comm.crud.service.impl.BaseBQImpls;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.office.bean.bo.ChopTypeBO;
import com.ruoyi.office.bean.vo.qo.ChopTypeQO;
import com.ruoyi.office.domain.ChopType;
import com.ruoyi.office.mapper.ChopTypeMapper;
import com.ruoyi.office.service.IChopTypeService;

/**
 * 案件类型信息 服务层处理
 * 
 * @author riverbo
 */
@Service
public class ChopTypeServiceImpl extends BaseBQImpls<ChopTypeMapper, ChopType, ChopTypeBO, ChopTypeQO> implements IChopTypeService {

	@Override
	public Boolean checkNameUnique(ChopType t) {
//        Long boId = StringUtils.isNull(t.getChopTypeId()) ? -1L : t.getChopTypeId();
//        Long dbId = this.baseMapper.getIdByName(t);
//        if (StringUtils.isNotNull(dbId) && dbId.longValue() != boId.longValue()) {
//            return UserConstants.NOT_UNIQUE;
//        }
        return UserConstants.UNIQUE;
	}
	
	public Map<Integer, List<ChopType>> getGroupMapList() {
		Map<Integer, List<ChopType>> map = new HashMap<>();
		List<ChopType> list = super.selectAll();
		if (!CollectionUtils.isEmpty(list)) {
			for (ChopType u : list) {
				List<ChopType> ls = map.get(u.getChopGroup());
				if (ls == null) {
					ls = new ArrayList<>();
				}
				ls.add(u);
				map.put(u.getChopGroup(), ls);
			}
		}
		return map;
	}
	
	public List<ChopType> getGroupRoot() {
		List<ChopType> ls = new ArrayList<>();
		for (int i=0; i<2; i++) {
			ChopType u = new ChopType();
			u.setChopTypeId(i+1);
			switch (i) {
				case 0: {
					u.setChopTypeName("行政用印");
					break;
				}
				case 1: {
					u.setChopTypeName("业务用印");
					break;
				}
			}
			ls.add(u);
		}
		return ls;
	}

}
